Skip to content

MutatingScope: Remove unnecessary union#4780

Closed
staabm wants to merge 2 commits into
phpstan:2.1.xfrom
staabm:remove-union
Closed

MutatingScope: Remove unnecessary union#4780
staabm wants to merge 2 commits into
phpstan:2.1.xfrom
staabm:remove-union

Conversation

@staabm

@staabm staabm commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

I think this is the 3rd time this week, which made me think that I need #4766 to implement some other stuff.

Lets see how you feel about it :-)

Comment on lines -3346 to -3355
$types = [
new ArrayType(new MixedType(), new MixedType()),
new ObjectType(ArrayAccess::class),
new NullType(),
];
if ($dimType->isInteger()->yes()) {
$types[] = new StringType();
}
$offsetValueType = TypeCombinator::intersect($exprVarType, TypeCombinator::union(...$types));

@staabm staabm Jan 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the actual change is here.

I am not sure why this no longer makes a difference.. maybe related to Type->setExistingOffset() and friends

Comment on lines -79 to -82
if ($type instanceof CompoundType) {
return $type->isAcceptedBy($this, $strictTypes);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is #4766 which makes sense on its own

@staabm staabm marked this pull request as ready for review January 19, 2026 09:26
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm

staabm commented Jan 19, 2026

Copy link
Copy Markdown
Contributor Author

ok - lets see what you think about it. in case you are fine with the change I can add regression tests for the issue-bot reports

@staabm staabm closed this Jan 19, 2026
@staabm staabm deleted the remove-union branch January 19, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants